<template>
  <div class="home">
    <div>
      <carousel :list="list"></carousel>
    </div>
    <div class="content">
      <div class="item" v-for="item in homeList" :key="item.id">
        <div class="l">
          <strong>{{item.title}}</strong>
          <p>{{item.target.desc}}</p>
          <span>作者：{{item.target.author.name}}</span>
        </div>
        <div class="r"><img :src="item.target.cover_url" alt=""></div>
      </div>
    </div>
  </div>
</template>

<script>
import Carousel from "@/components/Carousel.vue";

export default {
  name: "Home",
  components: { Carousel },
  data() {
    return {
      // 首页数据
      homeList: [],
      // 轮播图
      list: [
        {
          id: 1,
          imgUrl: require("../assets/imgs/banner1.png"),
        },
        {
          id: 2,
          imgUrl: require("../assets/imgs/banner2.png"),
        },
      ],
    };
  },
  created() {
    this.show();
  },
  methods: {
    show() {
      this.$axios.get("http://localhost:8080/data/home.json").then((res) => {
        if (res.status == 200) {
          this.homeList = res.data.recommend_feeds;
        }
      });
    },
  },
};
</script>
<style lang="less" scoped>
.home {
  overflow-x: hidden;
  width: 100vw;
  .content {
    width: 100%;
    overflow-y: scroll;
    margin-top: 15px;
    .item {
      display: flex;
      padding: 15px 10px 25px 10px;
      border-bottom: 2px solid rgb(226, 225, 225);
      .l {
        width: 62vw;
        strong {
          margin-right: 1px;
          display: block;
          font-size: 14px;
          font-weight: 600;
          margin-bottom: 2px;
          color: rgb(70, 67, 67);
          line-height: 18px;
        }
        p {
          font-size: 14px;
          color: rgb(183, 177, 177);
          line-height: 20px;
          width: 100%;
          display: -webkit-box;
          overflow: hidden;
          -webkit-line-clamp: 3;
          -webkit-box-orient: vertical;
        }
        span {
          display: flex;
          font-size: 13px;
          height: 25px;
          align-items: center;
          color: #ccc;
        }
      }
      .r {
        width: 33vw;
        img {
          height: 106px;
          width: 33vw;
          vertical-align: middle;
        }
      }
    }
  }
}
</style>
